/**
 * Created by IntelliJ IDEA
 * author: 张道阳
 * date: 2019/4/28 10:31
 * description:
 */
package cn.hmy.App.controller;

import cn.hmy.App.service.DevService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import java.util.HashMap;
import java.util.Map;

@Controller
@RequestMapping("devLoginController")
public class DeveloperController {
    @Autowired
    private DevService devService;

    @RequestMapping("/login")
    public String devLogin1(){
        return "devlogin";
    }

    @RequestMapping("devlogin")
    public ModelAndView devlogin(@RequestParam(value = "devCode") String devCode, @RequestParam(value = "devPassword") String devPassword, HttpServletRequest request, HttpSession session){
        ModelAndView mav=new ModelAndView();
        if (devCode!=null){
            if (devPassword!=null){
                Map map=new HashMap();
                map.put("devName","张道阳");
                mav.addObject("devUserSession",map);
                mav.setViewName("developer/main");
            }
            else {
                mav.setViewName("/403.jsp");
            }
        }
       else {
           request.setAttribute("message","登录失败！");
           mav.setViewName("devlogin");
        }
        return mav;
    }
}

